package com.example.xuyuli.controller;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionOnline implements HttpSessionListener {
    private int online = 0;
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        online++;
        System.out.println("creat se");
        se.getSession().getServletContext().setAttribute("online",online);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        online--;
        System.out.println("destroyed se");
        se.getSession().getServletContext().setAttribute("online",online);
    }
}
